import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { findCeqListData } from '/@/api/mes/mesScReport';

const { t } = useI18n('sys.empUser');

const modalProps = {
  title: t('EQ编号选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 80,
  schemas: [
    {
      label: t('EQ类型'),
      field: 'ceqtypecode',
      component: 'Input',
      ifShow: false,
    },
    {
      label: t('EQ编号'),
      field: 'ceqcode',
      component: 'Input',
    },
    {
      label: t('EQ名称'),
      field: 'ceqname',
      component: 'Input',
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('EQ编号'),
    dataIndex: 'ceqcode',
    // key: 'cus.code',
    // sorter: true,
    width: 100,
    align: 'left',
  },
  {
    title: t('EQ名称'),
    dataIndex: 'ceqname',
    // key: 'a.name',
    // sorter: true,
    width: 100,
    align: 'left',
  },
];

const tableProps: BasicTableProps = {
  api: findCeqListData,
  beforeFetch: (params) => {
    console.log(params, 'params');
    params['isAll'] = true;
    return params;
  },
  afterFetch: (data) => {
    // const dataList = data.map((item) => {
    //   item.ceqname = item.basCus.name;
    //   return item;
    // });
    return data;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'ceqcode',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'ceqcode',
  itemName: 'ceqname',
};
